package com.cy.action.backuser;

import java.util.ArrayList;
import java.util.List;

import com.cy.common.BaseAction;
import com.cy.condition.BackUserCondition;
import com.cy.entity.BackRole;
import com.cy.entity.BackUser;
import com.cy.service.BackRoleService;
import com.cy.service.BackUserService;

public class BackUserManageAction extends BaseAction{

	private static final long serialVersionUID = 7951148292316321577L;
	
	public BackUser backUser;
	
	private BackUserService backUserService;
	private BackRoleService backRoleService;
	
	private Integer firstResult = 0;
	private int maxResults = 10;
	private int count;
	private int currPage = 1;
	
	private BackUserCondition backUserCondition;
	private List<BackUser> backUsers;
	private List<BackRole> backRoles; 
	
	private List<String> roleStrs;
	
	private String control;								//用户判断操作
	
	public String execute() {
	//	if(backUserCondition!=null || backUser!=null){
			backUsers=new ArrayList<BackUser>();
			backUsers=backUserService.listBackUserByCondition(firstResult, maxResults, backUserCondition);
			count=backUserService.countBackUserByCondition(backUserCondition);
	//	}
		return SUCCESS;
	}
	
	public String addBackUser(){
		backRoleService.getAllObjects();
		return SUCCESS;
	}
	
	public String editBackUser(){
		backUser=(BackUser) backUserService.getObject(backUser.getId());
		return SUCCESS;
	}

	public String editBackUserRole(){
		roleStrs=new ArrayList<String>();
		backUser=(BackUser) backUserService.getObject(backUser.getId());
		List<BackRole> b=backUserService.listBackRoleByBackUser(backUser);
		for(BackRole backRole:b){
			roleStrs.add(backRole.getId()+"");
		}
		backRoles=backRoleService.getAllObjects();
		return SUCCESS;
	}
	
	public BackUser getBackUser() {
		return backUser;
	}

	public void setBackUser(BackUser backUser) {
		this.backUser = backUser;
	}

	public Integer getFirstResult() {
		return firstResult;
	}

	public void setFirstResult(Integer firstResult) {
		this.firstResult = firstResult;
	}

	public int getMaxResults() {
		return maxResults;
	}

	public void setMaxResults(int maxResults) {
		this.maxResults = maxResults;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getCurrPage() {
		return currPage;
	}

	public void setCurrPage(int currPage) {
		this.currPage = currPage;
	}

	public List<BackUser> getBackUsers() {
		return backUsers;
	}

	public void setBackUsers(List<BackUser> backUsers) {
		this.backUsers = backUsers;
	}

	public BackUserCondition getBackUserCondition() {
		return backUserCondition;
	}

	public void setBackUserCondition(BackUserCondition backUserCondition) {
		this.backUserCondition = backUserCondition;
	}

	public BackUserService getBackUserService() {
		return backUserService;
	}

	public void setBackUserService(BackUserService backUserService) {
		this.backUserService = backUserService;
	}

	public String getControl() {
		return control;
	}

	public void setControl(String control) {
		this.control = control;
	}

	public BackRoleService getBackRoleService() {
		return backRoleService;
	}

	public void setBackRoleService(BackRoleService backRoleService) {
		this.backRoleService = backRoleService;
	}

	public List<BackRole> getBackRoles() {
		return backRoles;
	}

	public void setBackRoles(List<BackRole> backRoles) {
		this.backRoles = backRoles;
	}

	public List<String> getRoleStrs() {
		return roleStrs;
	}

	public void setRoleStrs(List<String> roleStrs) {
		this.roleStrs = roleStrs;
	}
	
	
	
	
	
	

}
